package com.aimee.network.module.webpage.activity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;

import com.aimee.network.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 网页
 *
 * @author: czh
 * @time: 2019\10\24 0024
 */
public class WebPageActivity extends Activity {
    @BindView(R.id.btn_load_web_page)
    Button btnLoadWebPage;
    @BindView(R.id.btn_load_with_webview)
    Button btnLoadWithWebview;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_page);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.btn_load_web_page, R.id.btn_load_with_webview})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_load_web_page:
                loadWebPage();
                break;
            case R.id.btn_load_with_webview:
                break;
        }
    }

    /**
     * 调用本地默认浏览器来加载网址
     */
    private void loadWebPage() {
        Uri uri = Uri.parse("https://www.baidu.com");
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }

    /**
     * 使用WebView来加载网页，这样能达到在应用内显示网页的效果
     */
    private void loadWithWebView() {
    }
}
